package service

import (
	"context"
	"core/dao"
	"core/repo"
	"user/pb"
)

type NoticeService struct {
	newsDao *dao.NewsDao
	pb.UnimplementedGetNoticeServiceServer
}

func NewNoticeService(manager *repo.Manager) *NoticeService {
	return &NoticeService{
		newsDao: dao.NewNewsDao(manager),
	}
}

func (s *NoticeService) Register(ctx context.Context, req *pb.GetNoticeParams) (*pb.GetNoticeResponse, error) {
	data := s.newsDao.GetNotice(ctx, uint(req.Id))
	return &pb.GetNoticeResponse{
		Title:   data.Title,
		Content: data.Content,
	}, nil
}
